<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加新账户</title>
    <style>
        body {
            font-family: sans-serif;
            margin: 20px;
        }
        .container {
            max-width: 500px;
            margin: auto;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        label, input, button {
            display: block;
            margin-bottom: 10px;
            width: 95%;
        }
        input {
            padding: 8px;
        }
        button {
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        .message {
            margin-top: 15px;
            padding: 10px;
            border-radius: 3px;
        }
        .success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        .error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
        img {
            max-width: 100%;
            height: auto;
            margin-top: 15px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>添加新账户</h1>
        <form action="/add" method="post">
            <label for="account_name">账户名称:</label>
            <input type="text" id="account_name" name="account_name" required>
            <button type="submit">添加并生成二维码</button>
        </form>

        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="message {{ category }}">{{ message }}</div>
                {% endfor %}
            {% endif %}
        {% endwith %}

        {% if qr_code_url %}
            <h2>扫描二维码绑定</h2>
            <img src="{{ qr_code_url }}" alt="QR Code">
            <p><small>请使用您的身份验证器应用扫描此二维码。</small></p>
        {% endif %}

        <p><a href="/">返回令牌列表</a></p>
    </div>
</body>
</html>
